package models.data;

import play.data.validation.Constraints;
import play.db.ebean.Model;

import javax.persistence.Entity;
import javax.persistence.Id;
import java.text.SimpleDateFormat;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: bjornth
 * Date: 7.3.2013
 * Time: 14:20
 * To change this template use File | Settings | File Templates.
 */

@Entity
public class Annir extends Model {
    private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd.MM.yyyy");

    @Id
    @Constraints.Required
    public Integer onn_id;
    @Constraints.Required
    public String onn_heiti;

    public static Finder<Integer,Annir> find = new Finder<Integer,Annir>(
            Integer.class, Annir.class
    );

    public Annir() {
    }

    public Annir(Integer onn_id, String onn_heiti) {
        this.onn_id = onn_id;
        this.onn_heiti = onn_heiti;
    }

    public static List<Annir> fillSemesterList(String notandi_id) {
        List<Annir> annirs = Annir.find.where("trunc(sysdate) between dags_fra and dags_til").findList();
        return annirs;
    }

    public static Annir returnOnn(){
        Annir annir = Annir.find.where("trunc(sysdate) between dags_fra and dags_til").where().eq("undirskoli_id", 461).findUnique();
        return annir;
    }
}
